package com.gk.carshopsys.service;

import com.gk.carshopsys.dao.PartDao;
import com.gk.carshopsys.pojo.Part;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PartServiceImpl implements PartService {
    @Autowired
    private PartDao partDao;

    @Override
    public int addPartByList(List<Part> list) {
        return partDao.addPartByList(list);
    }

    @Override
    public List<Part> findPart(Part part,String low_price_s, String hight_price_s) {
        Long hight_price=null;
        Long low_price=null;

        if(low_price_s!=null && !low_price_s.equals("")){
            try{
                low_price = Long.valueOf(low_price_s);
            }catch (ClassCastException e){

            }
        }
        if(hight_price_s!=null && !hight_price_s.equals("")){
            try{
                hight_price = Long.valueOf(hight_price_s);
            }catch (ClassCastException e){

            }
        }

        return partDao.findPart(part,low_price,hight_price);
    }

    @Override
    public int addPart(Part part) {
        return partDao.addPart(part);
    }

    @Override
    public int updatePart(Part part) {
        return partDao.updatePart(part);
    }

    @Override
    public int delPart(List<Integer> part_list) {
        return partDao.delPart(part_list);
    }
}
